//
//  ZGrantDetailDealDisagreeVC.m
//  DistributorAB
//
//  Created by LZY on 2019/10/17.
//  Copyright © 2019 主事丫环. All rights reserved.
//

#import "ZGrantDetailDealDisagreeVC.h"
#import "ZGrantCheckDetailVC.h"//补助金详情

@interface ZGrantDetailDealDisagreeVC ()
@property (nonatomic, strong) UITextView *tvReason;//不通过原因
@end

@implementation ZGrantDetailDealDisagreeVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.title = @"不通过";
    [self.leftbutton setImage:imgname(@"left_icon") forState:(UIControlStateNormal)];
    self.view.backgroundColor = kColorWithHex(0xf2f2f2);
    
    [self setupViewAction];
}
#pragma mark - 界面布局
- (void)setupViewAction{
    UIView *viewBgBottom = [[UIView alloc] initWithFrame:CGRectMake(0, 10 + kNaviHeight, kScreen_Width, 196)];
    viewBgBottom.backgroundColor = kColorWithHex(0xffffff);
    [self.view addSubview:viewBgBottom];
    
    UIView *viewBgTop = [[UIView alloc] initWithFrame:CGRectMake(18, 24, kScreen_Width - 36, 132)];
    viewBgTop.backgroundColor = kColorWithHex(0xffffff);
    viewBgTop.layer.cornerRadius = 8;
    viewBgTop.layer.masksToBounds = YES;
    viewBgTop.layer.borderColor = kColorWithHex(0xcccccc).CGColor;
    viewBgTop.layer.borderWidth = 1;
    [viewBgBottom addSubview:viewBgTop];
    
    _tvReason = [[UITextView alloc] initWithFrame:CGRectMake(10, 10, viewBgTop.width - 20, viewBgTop.height - 20)];
    _tvReason.placeholder = @"请输入处理结果";
    [viewBgTop addSubview:_tvReason];
    
    UIButton *btnSubmit = [UIButton buttonWithType:UIButtonTypeCustom];
    [btnSubmit setTitle:@"提交" forState:UIControlStateNormal];
    [btnSubmit setTitleColor:kColorWithHex(0xffffff) forState:UIControlStateNormal];
    [btnSubmit setBackgroundColor:kColorWithHex(0x70be68)];
    btnSubmit.titleLabel.font = [UIFont systemFontOfSize:16];
    [btnSubmit addTarget:self action:@selector(btnSubmitClickAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btnSubmit];
    [btnSubmit mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view.mas_centerX);
        make.bottom.equalTo(self.view.mas_bottom).offset(-kScaleNum(113));
        make.size.mas_equalTo(CGSizeMake(kScaleNum(319), kScaleNum(48)));
    }];
}
#pragma mark - 交互事件
- (void)btnSubmitClickAction:(UIButton *)sender{
    NSString *resultStr = [_tvReason.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
    if (resultStr.length > 0) {
        kWeakSelf;
        NSMutableDictionary *param = [NSMutableDictionary dictionary];
        [param setObjectIfNotNil:@"0" forKey:@"agree"];
        [param setObjectIfNotNil:self.grantID forKey:@"id"];
        [param setObjectIfNotNil:resultStr forKey:@"reason"];
        [NetWorkTool POST:USER_APPROVAL_GRANTS param:param success:^(id dic) {
            ShowToastWithText(@"处理成功");
            [[NSNotificationCenter defaultCenter] postNotificationName:USER_DEAL_GRANT_SUCCESS object:nil];
            ZGrantCheckDetailVC *vc = [[ZGrantCheckDetailVC alloc] init];
            vc.grantID = self.grantID;
            vc.isFromDeal = YES;
            [weakSelf.navigationController pushViewController:vc animated:YES];
        } other:^(id dic) {
            ShowToastWithText(dic[@"msg"]);
        } fail:^(NSError *error) {
            
        } needUser:YES];
    }else{
        ShowToastWithText(@"请输入处理结果");
    }
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
